package AcWing;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author mu-chen
 * @create 2024-03-11 23:44
 */
public class Main91 {//12345678
    static final int N = 20, M = 1 << N, INF = 0x3f3f3f3f;
    static int n;
    static int[][] w = new int[N][N], f = new int[M][N];

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                w[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < M; i++) Arrays.fill(f[i], INF);
        f[1][0] = 0;
        for (int i = 0; i < 1 << n; i++) {
            for (int j = 0; j < n; j++) {
                if((i >> j & 1) == 1){
                    for (int k = 0; k < n; k++) {
                        if(((i - (1 << j) >> k) & 1) == 1)
                            f[i][j] = Math.min(f[i][j], f[i - (1 << j)][k] + w[k][j]);
                    }
                }
            }
        }
        System.out.println(f[(1 << n) - 1][n - 1]);
    }
}
